תוכנה 1 סמסטר א' תשע"א

Similar documents
תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה

תוכנה 1 * לא בהכרח בסדר הזה

מבוא למדעי המחשב תרגול 8 רשימה משורשרת כללית, Comparator

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes

הנכות 1 םוכיס לוגרת 14 1

הנכות 1 תואיגש םע תודדומתהו תואלול,םי : כרעמ 2 לוגרת

הנכות 1 תואיגש םע תודדומתהו תואלול,םיכרעמ : לו 2 גרת

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

תוכנה 1 תרגול 2: מערכים ומבני בקרה

תוכנה 1 תרגול 2: מערכים, מבני בקרה ושגיאות

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Array Creation and Initialization. Loop through Arrays

תוכנה 1 3 תרגול מס' מערכים ומבני בקרה

תור שימושים בעולם התוכנה

תוכנה 1 מערכים. Array Creation and Initialization. Array Declaration. Loop through Arrays. Array Creation and Initialization

משתנים שעור מס. 2 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

הנכות 1 םוכיס לוגרת 13 1

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

לתיכנות עם MATLAB Lecture 5: Boolean logic and Boolean expressions

הנכות 1 םוכיס לוגרת 13 1

תזכורת: עץבינארי מבוא למדעי המחשב הרצאה 24: עצי חיפוש בינאריים

תרגול 3 מערכים ופונקציות

JAVA OPERATORS GENERAL

תוכנה 1 בשפת Java תרגול מספר 9: הורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

תכנות מונחה עצמים משחקים תשע"ו

Simple Web Service. namespace MyService { public class Service1 : System.Web.Services.WebService {

תוכנה 1. תרגול מספר 11: Static vs. Dynamic Binding מחלקות מקוננות Nested Classes בית הספר למדעי המחשב אוניברסיטת תל אביב

מחרוזות ב Java ותכנות מונחה בדיקות )Test Driven Development(

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

Basic operators, Arithmetic, Relational, Bitwise, Logical, Assignment, Conditional operators. JAVA Standard Edition

BankAccount account1 = new BankAccount(...);,this

תוכנה 1 בשפת Java נושאים שונים בהורשה רובי בוים ומתי שמרת בית הספר למדעי המחשב אוניברסיטת תל אביב

Practical Session No. 14 Topological sort,amortized Analysis

תוכנה 1 תרגול מספר 13

תוכנה 1 תרגול מספר 13

ב ה צ ל ח ה! אוניברסיטת בן גוריון בנגב מספר נבחן : תאריך המבחן: כ"ה תשרי תשע"ח 15/10/17 שמות המורים: ציון סיקסיק מיועד לתלמידי : א'

גיליון תשובות מספר נבחן: סעיף ג (10 נקודות) הגדרת בטיחות הינה שמירה על האינווריאנטה של האובייקטים במהלך ההרצה.

בית הספר למדעי המחשב אוניברסיטת תל אביב תוכנה 1 תרגול מספר 9: הורשה מחלקות אבסטרקטיות חריגים

תוכנה 1 ומחלקות פנימיות

הנכות 1 םוכיס לוגרת 13 1

מערכים שעור מס. 4 כל הזכויות שמורות דר ' דרור טובי המרכז האוניברסיטאי אריאל 1

תרגול מספר 3: מערכים

סכום (סדרת ערכים) אחרת - דוגמא: סכום-ספרות (num) אם < 10 num החזר 1 או אם = 0 = num החזר 0 public static int numofdigits (int num)

מבוא לתכנות ב- JAVA תרגול 7

היצביט ומ - ןוכית ת וי נבת

גיליון תשובות מספר נבחן:

תרגול 3 מערכים ופונקציות

מבוא לתכנות ב- JAVA מעבדה 4

public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;

ת ונכת סרוק תורשוקמ תומישר :יעישת רועיש 1

Practice problem on defining and using Class types. Part 4.

9. טופס הזמנת מוצרים טופס ההזמנה הוא טופס מורכב. מעורבים בו 4 טבלאות נתונים. קשרי הגומלין בין הטבלאות : הטופס :

מצליחה. 1. int fork-bomb() 2. { 3. fork(); 4. fork() && fork() fork(); 5. fork(); printf("bla\n"); 8. return 0; 9. }

Object-Oriented Programming. Topic 2: Fundamental Programming Structures in Java

Expressions & Flow Control

Amortized Analysis, Union-Find,

שיעור מספר 3: "מחלקות וטיפוסים"

The single cycle CPU

קורס תכנות רשימה מקושרת דוגמה: חיפוש מעבר על רשימה דוגמא: שחרור רשימה מקושרת דוגמא: הוספת אברים שלא בהתחלה

שיעור מספר 8: "אמא יש רק אחת" )הורשה I(

שאלה 1 מהו הפלט של התוכנית הבאה:

The Java language has a wide variety of modifiers, including the following:

קורס תכנות שיעור שני: שימוש במשתנים,

תוכנה 1 טיפוסי השפה טיפוסים לא פרימיטיביים הטיפוסים הפרימיטיביים מחרוזות המרה למספרים תרגול 2: טיפוסי שפה, מחרוזות, מערכים ושגיאות

תרשים המחלקות ותרשים העצמים

הוראות חיבור e-port בפרוטוקול Art-Net למערכות תאורה שונות

נתונות שתי המחלקות הבאות:

תרגול מס' 5: IO )קלט-פלט(

תרגול 6 רקורסיה ותכנות מונחה עצמים

הקלחמ ה תמרב ת ונ וכ ת (static members ) יליזרב דהוא Java תפשב ם דקת מ תונכת ביבא ל ת תטיסרבינוא

Practical Session - Heap

C02: Overview of Software Development and Java

CT 229. Java Syntax 26/09/2006 CT229

Handout 8 Classes and Objects Continued: Static Variables and Constants.

Programming for Engineers in Python

Programming for Engineers in Python

פיתוח מערכות תוכנה מבוססות Java אוהד ברזילי

תרגול 12. Standard Template Library כתיבת אלגוריתמים גנריים מצביעים חכמים

LAB A Translating Data to Binary

מבוא לתכנות מערכות מבחן מועד א' סמסטר חורף

CS 11 java track: lecture 1

Introduction to Programming (Java) 2/12

תכנות מתקדם בשפת C משתנים

A flow chart is a graphical or symbolic representation of a process.

Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

סעיף ב )11 נקודות( public synchronized void advance(staircase staircase) throws InterruptedException staircase!

תוכנה 1 תרגול מספר 10: תרגיל חזרה חברת הייטק בית הספר למדעי המחשב אוניברסיטת תל אביב

- מבחן. - 4 עבודות ב- JAVA. הגשה בזוגות דרך ה- System Submission

ספרית התבניות הסטנדרטית (STL) כתיבת אלגוריתמים גנריים מצביעים חכמים. .vector. list iterator נכיר תחילה את האוסף הפשוט ביותר בספריה

Outline for Today CSE 142. CSE142 Wi03 G-1. withdraw Method for BankAccount. Class Invariants

ASP.Net Web API.

ASSIGNMENT 5 Objects, Files, and a Music Player

מבוא למדעי המחשב תירגול 3:

Lecture 3. COMP1006/1406 (the Java course) Summer M. Jason Hinek Carleton University

CS52 - Assignment 8. Due Friday 4/15 at 5:00pm.

Engineering Programming A

מבוא לתכנות תוכנית שעור מס. 1 1 דר' דרור טובי, המרכז האוניברסיטאי אריאל בשומרון.

- MEAN Stack חזרה. MongoDB - as the database Express - as the web framework AngularJS - as the frontend framework NodeJS- as the server platform

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

רשימות דילוגים Skip Lists

Transcription:

General Tips on Programming תוכנה 1 סמסטר א' תשע"א תרגול מס' 6 מנשקים, דיאגרמות וביטים * רובי בוים ומתי שמרת Write your code modularly top-down approach Compile + test functionality on the fly Start with an empty program/classes Add content gradually and keep testing If something goes wrong, probably the bug is in the latest change * לא בהכרח בסדר הזה General Tips on Programming Even More Tips Use the Debugger to follow your execution flow and find what went wrong Understanding is good but not enough you must practice! Based on a true story: Do not send us code Do not send us emails saying the code you gave us does not work, before you make sure the original given code is problematic When you ask questions be as specific as you can, give as much information about the problem and your trials as possible Even More Tips Late submissions / appeals on homework grades? Please contact the graders odedelba@post.tau.ac.il המערכת הבנקאית נתאר את מערכת התוכנה שלנו בעזרת דיאגרמות דיאגרמות סטטיות: תיאור היחסים בין המחלקות השונות במערכת דיאגרמות דינאמיות: תיאור ההתנהגות של המערכת בזמן ריצה מצב האוביקטים תיאור של תרחיש 6 1

Class Diagram המחלקה Customer Customer Account public Account(Customer customer, long id) public withdraw(double amount) public (double amount) public transferto(double amount, Account otheraccount) public double getbalance() public Customer getowner() public double getnumber() Aggregation (has-a) public Customer(String name, String id) * public String getname() public String getid() main Association 7 public class Customer public Customer(String name, String id) this.name = name; this.id = id; public String getname() return name; public String getid() return id; private String name; private String id; 8 Toy Program public class public static main(string[] args) 9 10 main ( ) Toy Program public class public static main(string[] args) "024847638" 11 12 main ( ) customer2: "Rita Stein" 2

Toy Program public class public static main(string[] args) Account: number: 1234 Account: number: 2984 Account: number: 5678 "024847638" "Rita Stein" 13 14 main ( ) customer2: account1: account2: account3: Message Sequence Chart Message Sequence Chart public class public static main(string[] args) 15 16 time main 1000 100, account3 account1 account2 account3 balance: 900 number: 1234 500 transferto 300 balance: 200 number: 5678 withdraw 100 balance: 100 number: 2984 Output מנשקים public class public static main(string[] args) output: account1 has 900.0 account2 has 200.0 17 מנשק )interface( הוא מבנה תחבירי ב Java המאפשר לחסוך בקוד לקוח קוד אשר משתמש במנשק יוכל בזמן ריצה לעבוד עם מגוון מחלקות המממשות את המנשק הזה )ללא צורך בשכפול הקוד עבור כל מחלקה( דוגמא: נגן מוזיקה אשר מותאם לעבוד עם קובצי מוזיקה )mp3( ועם קובצי וידאו )mp4( 3

Playing Mp3 Playing VideoClips public class MP3Song public class Player public class VideoClip public class Player public play() private boolean repeat; public play() // same as before... // audio codec calculations, private boolean shuffle; // video codec calculations, // play the song... public playsongs(mp3song[] songs) do // play the clip... public playvideos(videoclip[] clips) do // does complicated stuff // does complicated stuff Collections.shuffle(Arrays.asList(clips)); // related to MP3 format... Collections.shuffle(Arrays.asList(songs)); // related to MP4 format... for (MP3Song song : songs) for (VideoClip videoclip : clips) videoclip.play(); song.play(); while (repeat); while (repeat); שימוש במנשק שכפול קוד public playsongs(mp3song[] songs) do Collections.shuffle(Arrays.asList(songs)); for (MP3Song song : songs) song.play(); while (repeat); למרות ששני השרותים נקראים play() אלו פונקציות שונות! public play (Playable[] items) do Collections.shuffle(Arrays.asList(items)); for (Playable item : items) item.play(); public playvideos(videoclip[] clips) do Collections.shuffle(Arrays.asList(clips)); for (VideoClip videoclip : clips) videoclip.play(); while (repeat); public interface Playable public play(); while (repeat); נרצה למזג את שני קטעי הקוד מימוש המנשק ע"י הספקים public class VideoClip implements Playable @Override public play() // render video, play the clip on screen... // does complicated stuff related to video formats... public class MP3Song implements Playable @Override public play() // audio codec calculations, play the song... // does complicated stuff related to MP3 format... מערכים פולימורפים Playable[] playables = new Playable[3]; playables[0] = new MP3Song(); playables[1] = new VideoClip(); playables[2] = new MP4Song(); // new Playable class Player player = new Player(); // init player... public play (Playable [] items) player.play(playables); עבור כל איבר במערך יקרא ה play() המתאים do Collections.shuffle(Arrays.asList(items)); for (Playable item : items) item.play(); while (repeat); 4

פעולות על סיביות - דוגמאות פעולות על סיביות אופרטורים לביצוע פעולות על ביטים רק על טיפוסים איטנגרליים char( )int, short, byte, ~ << >> >>> & ^ Unary bitwise complement Signed left shift Signed right shift Unsigned right shift Bitwise AND Bitwise XOR Bitwise OR 25 3 ~3-3 3 << 2-3 >> 1-3 >>> 1 ייצוג בינארי 00000000000000000000000000000011 11111111111111111111111111111100 11111111111111111111111111111101 00000000000000000000000000001100 11111111111111111111111111111110 01111111111111111111111111111110 int 32 ביטים מה נקבל מ & 3?i שני הביטים הימניים של i ומה נקבל מ?i & 0xF0 26 5